package nmrworkflow.framework.functionwrappers.nmrpipe;

import nmrworkflow.framework.functionwrappers.Argument;
import nmrworkflow.framework.functionwrappers.Function;

/**
 * Wraps NMRPipe Extract Function
 * @author rjn
 *
 */
public class NmrPipeExt extends BaseNmrPipeWrapper {
	
	private int startPercent;
	private int endPercent;
	private boolean adjustSweepWidth;
	
	/**
	 * Arguments must be between 0 and 100.
	 * @param start
	 * @param end
	 */
	public NmrPipeExt(int start, int end, boolean adjustSweepWidth) {
		super();
		
		this.setStartPercent(start);
		this.setEndPercent(end);
		this.setAdjustSweepWidth(adjustSweepWidth);
		
	}

	@Override
	protected Function buildFunction() {
		Function ext = new Function("EXT");
		if(this.adjustSweepWidth)
			ext.addArgument(new Argument("sw", ""));
		ext.addArgument(new Argument("reg", new String[] {this.startPercent + "%", this.endPercent + "%"}));
		
		return ext;
	}
	
	public int getEndPercent() {
		return endPercent;
	}
	
	/**
	 * Argument must be between 0 and 100
	 * @param endPercent
	 */
	public void setEndPercent(int endPercent) {
		if(0 <= endPercent && endPercent <= 100)
			this.endPercent = endPercent;
	}

	public int getStartPercent() {
		return startPercent;
	}
	
	/**
	 * Argument must between 0 and 100
	 * @param startPercent
	 */
	public void setStartPercent(int startPercent) {
		if(0 <= startPercent && startPercent <= 100)
			this.startPercent = startPercent;
	}

	public boolean isAdjustSweepWidth() {
		return adjustSweepWidth;
	}

	public void setAdjustSweepWidth(boolean adjustSweepWidth) {
		this.adjustSweepWidth = adjustSweepWidth;
	}
	
	

}
